package com.guldan.core.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Silas.
 * Date: 2016/12/3
 * Time: 18:07
 */
public enum ProjectRegisterBatchEn {

    register_ing(10, "乡镇登记中，待上报"),

    auditor_ing(20, "乡镇登记待复核"),
    auditor_ed(30, "乡镇登记复核通过，待上报"),

    org_auditor_ing(50, "主管部门待审批"),
    org_auditor_ed(60, "主管部门审批通过，待汇总上报"),


    finance_auditor_ing(80, "县财部门待审核"),
    finance_auditor_ed(90, "县财政局审核通过，待生成待发文件"),
    finance_auditor_fail(100, "县财政局审核不通过"),


    finance_created_file(110, "已生成代发文件，待下载"),
    finance_downloaded_file(120, "财政已下载，银行处理中"),

    bank_success_all(200, "全部发放成功"),
    bank_fail_all(210, "全部发放失败"),
    bank_success_part(220, "部分发放成功");

    private Integer code;
    private String mean;

    ProjectRegisterBatchEn(Integer code, String mean) {
        this.code = code;
        this.mean = mean;
    }

    public static ProjectRegisterBatchEn toEnum(Integer code) {
        ProjectRegisterBatchEn[] values = values();
        for (ProjectRegisterBatchEn en : values) {
            if (en.getCode().equals(code)) {
                return en;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getMean() {
        return mean;
    }

    public static List<EnumDTO> getList() {
        List<EnumDTO> list = new ArrayList<>();
        for (int k = 0; k < values().length; k++) {
            list.add(new EnumDTO(values()[k].getCode(), values()[k].getMean(), ""));
        }
        return list;
    }

    //批次状态是否是完结状态
    public static Boolean isOver(Integer code) {

        if (code.equals(bank_fail_all.getCode()) || code.equals(bank_success_all.getCode()) || code.equals(bank_success_part.getCode())) {
            return true;
        } else {
            return false;
        }
    }

    //获取财政角色，非待审批状态
    public static List<Integer> getFinanceFileMenuList() {
        List<Integer> state = new ArrayList<>();
        state.add(finance_auditor_ed.getCode());
        state.add(finance_created_file.getCode());
        state.add(finance_downloaded_file.getCode());
        state.add(bank_success_all.getCode());
        state.add(bank_fail_all.getCode());
        state.add(bank_success_part.getCode());
        return state;
    }

    //获取所有状态id列表
    public static List<Integer> getAll() {
        List<Integer> state = new ArrayList<>();
        for (int k = 0; k < values().length; k++) {
            state.add(values()[k].getCode());
        }
        return state;
    }

    public static List<Integer> getOverStateList() {
        List<Integer> list = new ArrayList<Integer>();

        list.add(bank_success_all.getCode());
        list.add(bank_fail_all.getCode());
        list.add(bank_success_part.getCode());

        return list;
    }


}
